home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 013 / size.arc / SIZE.XC < prev   
Encoding:
Text File  |  1987-01-10  |  7.9 KB  |  201 lines

  1. SIZE.C                                                                Page 1
  2. [file d/t= 01/10/87  10:14]            [clock d/t= 10 January 1987  10:18:31]
  3.  
  4.  
  5.    1 #define LINT_ARGS 1
  6.    2 #include <dos.h>
  7.    3 #include <string.h>
  8.    4 #include <memory.h>
  9.    5 #include <stdio.h>
  10.    6 #include <process.h>
  11.    7 
  12.    8 main(argc, argv)
  13.    9 int argc;
  14.   10 char *argv[];
  15.   11 {
  16.   12 
  17.   13         int i, j;
  18.   14         char file_name[80];
  19.   15         static int num_files = 0;       /* number of files checked */
  20.   16         char dta[128];
  21.   17         static long total = 0;          /* total size of all files */
  22.   18         static long size = 0;
  23.   19         static long tot_cl[] = {0, 0, 0, 0};    /* total clusters required */
  24.   20         static long max_cl[] = {315, 354, 316, 355};
  25.   21         static char over[]="**OVER**";          /* overflow message */
  26.   22         static char noover[]="        ";        /* no overflow */
  27.   23         char far *fn_fp;
  28.   24         char far *dta_fp;
  29.   25         char *ovmsg[4];
  30.   26         union REGS inregs;
  31.   27         union REGS outregs;
  32.   28         struct SREGS segregs;
  33.   29 
  34.   30         fn_fp = file_name;
  35.   31         dta_fp = dta;
  36.   32 
  37.   33         if(argc > 1) {
  38.   34                 strcpy(file_name, argv[1]);
  39.   35                 if(!strchr(file_name, '.')) {
  40.   36                         if(file_name[strlen(file_name) - 1] != '\\')
  41.   37                                 strcat(file_name, "\\*.*");
  42.   38                         else
  43.   39                                 strcat(file_name, "*.*");
  44.   40                 }
  45.   41         } else
  46.   42                 strcpy(file_name, "*.*");
  47.   43 
  48.   44         segread(&segregs);              /* read current value of seg regs */
  49.   45 
  50.   46         inregs.h.ah = 0x1A;             /* set current dta address */
  51.   47         segregs.ds = FP_SEG(dta_fp);
  52.   48         inregs.x.dx = FP_OFF(dta_fp);
  53.   49         intdosx(&inregs, &outregs, &segregs);
  54.   50 
  55.   51         segregs.ds = FP_SEG(fn_fp);
  56.   52         inregs.x.dx = FP_OFF(fn_fp);
  57.   53         inregs.x.cx = 0;
  58.   54         inregs.h.ah = 0x4E;
  59.   55 
  60. SIZE.C                                                                Page 2
  61. [file d/t= 01/10/87  10:14]            [clock d/t= 10 January 1987  10:18:31]
  62.  
  63.   56         intdosx(&inregs, &outregs, &segregs);   /* search for first file */
  64.   57 
  65.   58         if(outregs.x.cflag == 0) {              /* if file found */
  66.   59                 ++num_files;
  67.   60                 memcpy(&size, &dta[26], 4);
  68.   61                 for(i = 0, j = 1; i < 4; i++, j *= 2)
  69.   62                         tot_cl[i] += cluster(size, j);
  70.   63                 total += size;
  71.   64 
  72.   65                 do {                            /* find rest of files */
  73.   66                         inregs.h.ah = 0x4F;     /* find next file */
  74.   67                         intdos(&inregs, &outregs);
  75.   68 
  76.   69                         if(outregs.x.cflag == 0) {    /* if file found */
  77.   70                                 ++num_files;
  78.   71                                 memcpy(&size, &dta[26], 4);
  79.   72                                 for(i = 0, j = 1; i < 4; i++, j *= 2)
  80.   73                                         tot_cl[i] += cluster(size, j);
  81.   74                                 total += size;
  82.   75                         }
  83.   76                 } while (outregs.x.cflag == 0);
  84.   77         }
  85.   78 
  86.   79         printf("\n\nNOTE:  FULL PATHNAMES AND/OR FILENAMES MAY BE USED");
  87.   80         printf(" AS ARGUMENT ON PROGRAM LINE");
  88.   81         printf("\n\n\tNumber of files = %d     Total size = %ld bytes",
  89.   82                 num_files, total);
  90.   83 
  91.   84         printf("\n\n\n       ");
  92.   85         printf("TOTAL STORAGE REQUIRED IN BYTES FOR THE FOLLOWING DISKS");
  93.   86         printf("\n\n   160K SS     180K SS     320K DS     360K DS     ");
  94.   87         printf("10 MEG     20+MEG");
  95.   88         printf("\n   floppy      floppy      floppy      floppy       ");
  96.   89         printf("hard       hard");
  97.   90         printf("\n\n  %8ld    %8ld    %8ld    %8ld   %8ld   %8ld",
  98.   91                 tot_cl[0] * 512L, tot_cl[0] * 512L, tot_cl[1] * 1024L,
  99.   92                 tot_cl[1] * 1024L, tot_cl[3] * 4096L, tot_cl[2] * 2048L);
  100.   93         for(i = 0; i < 2; i++)
  101.   94                 if(tot_cl[0] > max_cl[i])
  102.   95                         ovmsg[i] = over;
  103.   96                 else
  104.   97                         ovmsg[i] = noover;
  105.   98         for(; i < 4; i++)
  106.   99                 if(tot_cl[1] > max_cl[i])
  107.  100                         ovmsg[i] = over;
  108.  101                 else
  109.  102                         ovmsg[i] = noover;
  110.  103         printf("\n  %s    %s    %s    %s\n\n", ovmsg[0], ovmsg[1], ovmsg[2],
  111.  104                 ovmsg[3]);
  112.  105 
  113.  106         exit(0);
  114.  107 
  115.  108 }
  116.  109 
  117.  110 cluster(file_size, num_sec)
  118.  111 long file_size;
  119. SIZE.C                                                                Page 3
  120. [file d/t= 01/10/87  10:14]            [clock d/t= 10 January 1987  10:18:31]
  121.  
  122.  112 int num_sec;
  123.  113 {
  124.  114 
  125.  115         int num_clust;          /* number of clusters required */
  126.  116 
  127.  117         num_sec *= 512;         /* number of bytes per cluster */
  128.  118         num_clust = file_size / (long)num_sec;
  129.  119         if(file_size > ((long)num_sec * (long)num_clust))
  130.  120                 ++num_clust;
  131.  121 
  132.  122         return(num_clust);
  133.  123 
  134.  124 }
  135.  125  SIZE.C                                                                Page 4
  136. [file d/t= 01/10/87  10:14]            [clock d/t= 10 January 1987  10:18:31]
  137.  
  138.  
  139. ah            : 46    54    66    
  140. argc          : 8     9     33    
  141. argv          : 8     10    34    
  142. cflag         : 58    69    76    
  143. cluster       : 62    73    110   
  144. cx            : 53    
  145. ds            : 47    51    
  146. dta           : 16    31    60    71    
  147. dta_fp        : 24    31    47    48    
  148. dx            : 48    52    
  149. exit          : 106   
  150. FP_OFF        : 48    52    
  151. FP_SEG        : 47    51    
  152. far           : 23    24    
  153. file_name     : 14    30    34    35    36    36    37    39    
  154.               : 42    
  155. file_size     : 110   111   118   119   
  156. fn_fp         : 23    30    51    52    
  157. h             : 46    54    66    
  158. i             : 13    61    61    61    62    72    72    72    
  159.               : 73    93    93    93    94    95    97    98    
  160.               : 98    99    100   102   
  161. inregs        : 26    46    48    49    52    53    54    56    
  162.               : 66    67    
  163. intdos        : 67    
  164. intdosx       : 49    56    
  165. j             : 13    61    61    62    72    72    73    
  166. L             : 91    91    
  167. LINT_ARGS     : 1     
  168. main          : 8     
  169. max_cl        : 20    94    99    
  170. memcpy        : 60    71    
  171. noover        : 22    97    102   
  172. num_clust     : 115   118   119   120   122   
  173. num_files     : 15    59    70    82    
  174. num_sec       : 110   112   117   118   119   
  175. outregs       : 27    49    56    58    67    69    76    
  176. over          : 21    95    100   
  177. ovmsg         : 25    95    97    100   102   103   103   103   
  178.               : 104   
  179. printf        : 79    80    81    84    85    86    87    88    
  180.               : 89    90    103   
  181. REGS          : 26    27    
  182. SREGS         : 28    
  183. segread       : 44    
  184. segregs       : 28    44    47    49    51    56    
  185. size          : 18    60    62    63    71    73    74    
  186. strcat        : 37    39    
  187. strchr        : 35    
  188. strcpy        : 34    42    
  189. strlen        : 36    
  190. tot_cl        : 19    62    73    91    91    91    92    92    
  191.               : 92    94    99    
  192. total         : 17    63    74    82    
  193. x             : 48    52    53    58    69    76    
  194. SIZE.C                                                                Page 5
  195. [file d/t= 01/10/87  10:14]            [clock d/t= 10 January 1987  10:18:31]
  196.  
  197.  
  198.  
  199. Allowable Symbols: 749
  200. Unique    Symbols: 48
  201.